package org.dj.eoms.system.service;

import org.dj.eoms.system.bean.SysUserBean;
import org.dj.eoms.system.dao.SysUserDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * Project Name: eoms
 * Vsersion : 0.0.1
 * Created by DengJun on 16/1/20.
 */
@Service
public class LoginService {

    @Autowired
    protected SysUserDao userDao;


    public SysUserBean getUserByAccount(String account){
        return userDao.getUserByAccount(account);
    }

    public boolean loginByAccountAndPwd(String account,String password) throws Exception {
        SysUserBean userBean = userDao.getUserByAccount(account);
        if (userBean == null){
            throw new Exception("The User is not Exists!");
        }
        if (userBean.getPassword().equals(password)){
            return true;
        }else{
            throw new Exception("The password is not correct!");
        }
    }

}
